//
//  PTStuLSDemandDetailContentCell.m
//  PlanTech
//  需求详情-内容Cell
//  Created by ruifeng song on 2018/7/11.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "PTStuLSDemandDetailContentCell.h"
#import "SINACalendarUtils.h"

@interface PTStuLSDemandDetailContentCell()

@property(nonatomic,strong)UILabel * serviceTypeLabel;
@property(nonatomic,strong)UILabel * receiveGoodsLabel;
@property(nonatomic,strong)UILabel * codeLabel;
@property(nonatomic,strong)UILabel * serviceContentLabel;
@property(nonatomic,strong)UILabel * userAddressLabel;
@property(nonatomic,strong)UILabel * userAddressTitleLabel;
@end

@implementation PTStuLSDemandDetailContentCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _serviceTypeLabel= [[UILabel alloc]initWithFrame:CGRectMake(22,0,ScreenWidth - 24 - 44, 13)];
//        _serviceTypeLabel.text = @"服务类型：超市代购";
        _serviceTypeLabel.textColor = PTColor_2e2e2e;
        _serviceTypeLabel.font = PTFONT_13;
        [self.contentView addSubview:_serviceTypeLabel];
        
        _receiveGoodsLabel= [[UILabel alloc]initWithFrame:CGRectMake(22,_serviceTypeLabel.bottom + 10,_serviceTypeLabel.width, 13)];
//        _receiveGoodsLabel.text = @"收货时间：12:00-14:00";
        _receiveGoodsLabel.font = PTFONT_13;
        _receiveGoodsLabel.textColor = PTColor_2e2e2e;
        [self.contentView addSubview:_receiveGoodsLabel];
        
        _userAddressTitleLabel= [[UILabel alloc]initWithFrame:CGRectMake(22, _receiveGoodsLabel.bottom + 10, 70, 13)];
        _userAddressLabel.text = @"收货地址：";
        _userAddressTitleLabel.font = PTFONT_13;
        _userAddressTitleLabel.textColor = PTColor_2e2e2e;
        [self.contentView addSubview:_userAddressTitleLabel];
        
        _userAddressLabel= [[UILabel alloc]initWithFrame:CGRectMake(_userAddressTitleLabel.right, _receiveGoodsLabel.bottom, _receiveGoodsLabel.width - 70, 26)];
        //        _userAddressLabel.text = @"大大撒大大所大萨达撒大所多大事大回复大叔大婶大大叔大婶大大大大大声道鼓捣";
        _userAddressLabel.font = PTFONT_13;
        _userAddressLabel.numberOfLines = 5;
        _userAddressLabel.textColor = PTColor_2e2e2e;
        [self.contentView addSubview:_userAddressLabel];
        
        _codeLabel= [[UILabel alloc]initWithFrame:CGRectMake(22, _userAddressLabel.bottom +10, _receiveGoodsLabel.width, 13)];
        //        _phoneLabel.text = @"联系电话：18888888888";
        _codeLabel.textColor = PTColor_2e2e2e;
        _codeLabel.font = PTFONT_13;
        [self.contentView addSubview:_codeLabel];
        
        _serviceContentLabel= [[UILabel alloc]initWithFrame:CGRectMake(22,_codeLabel.bottom + 10, _receiveGoodsLabel.width, 13)];
        //        _serviceContentLabel.text = @"快递点：山西大学东门";
        _serviceContentLabel.font = PTFONT_13;
        _serviceContentLabel.textColor = PTColor_2e2e2e;
        [self.contentView addSubview:_serviceContentLabel];

    }
    return self;
}

-(void)updateDemandDetailContentCellWith:(LifeServiceListDetailModel *)detailModel
{
    
    NSString *startimeStr=[NSString stringWithFormat:@"%@",detailModel.startTime];
    NSString *endTimeStr=[NSString stringWithFormat:@"%@",detailModel.endTime];
    
    self.receiveGoodsLabel.text = [NSString stringWithFormat:@"收货时间：%@-%@",[SINACalendarUtils getDateStringWithTimeStr:startimeStr andFormat:@"MM月dd日 HH:mm"],[SINACalendarUtils getDateStringWithTimeStr:endTimeStr andFormat:@"HH:mm"]];
    
    //type;              //类型 （8 快递，9 打印复印，10 捎饭带饭，11 超市代购）
    
    NSString * serviceType = @"";
    NSString * serviceName = @"";
    NSString * serviceAddress = @"";
    
    NSString * destinationAddress =@"";
    NSString * destinationName=@"";
    
    switch ([detailModel.type integerValue]) {
        case PTLifeService_ExpressType:
            serviceType = @"代取快递";
            serviceName = @"取货码：******(承接后可见)";
            serviceAddress = @"快递点：";
            destinationAddress = detailModel.destinationAddress;
            destinationName = @"";
            break;
        case PTLifeService_PrintType:
        {
            serviceType = @"打印复印";
            serviceName = @"打印份数：";
            serviceAddress = @"打印地点：";
            if (detailModel.copies ==nil) {
                detailModel.copies = [NSNumber numberWithInteger:0];
            }
            destinationName = [NSString stringWithFormat:@"%@",detailModel.copies];
            destinationAddress = detailModel.destinationAddress;
        }
            break;
        case PTLifeService_BuyMealType:
            serviceType = @"捎饭带饭";
            serviceName = @"餐厅名称：";
            serviceAddress = @"餐厅地址：";
            destinationName = detailModel.destinationName;
            destinationAddress = detailModel.destinationAddress;
            break;
        case PTLifeService_HotboomType:
            serviceType = @"超市代购";
            serviceName = @"超市名称：";
            serviceAddress = @"超市地点：";
            destinationName = detailModel.destinationName;
            destinationAddress = detailModel.destinationAddress;
            break;
    }
    
    self.serviceTypeLabel.text = [NSString stringWithFormat:@"服务类型：%@", serviceType];
    
    self.userAddressTitleLabel.text= @"收货地址：";
    self.userAddressLabel.text = [NSString stringWithFormat:@"%@",detailModel.userAddress];

    CGFloat sizeHeight = [self.userAddressLabel.text heightForFont:self.userAddressLabel.font width:self.userAddressLabel.width];
    [self.userAddressLabel setFrame:CGRectMake(self.userAddressTitleLabel.right, self.receiveGoodsLabel.bottom + 9, self.serviceContentLabel.width - 60, sizeHeight)];
    
    self.codeLabel.text = [NSString stringWithFormat:@"%@%@",serviceName,destinationName];
    
    self.serviceContentLabel.text = [NSString stringWithFormat:@"%@%@",serviceAddress,destinationAddress];
    
    [self.codeLabel setFrame:CGRectMake(22, self.userAddressLabel.bottom +10, self.receiveGoodsLabel.width, 13)];
    [self.serviceContentLabel setFrame:CGRectMake(22,self.codeLabel.bottom + 10, self.receiveGoodsLabel.width, 13)];
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
